package com.wf.ew.storage.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.User;
import com.wf.ew.storage.biz.ProductBiz;
import com.wf.ew.storage.model.Product;
import com.wf.ew.storage.service.ProductService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2019-11-18 00:42:44
 * @version ：1.0
 */
@Service
public class ProductServiceImpl implements ProductService {

	@Autowired
	private ProductBiz productBiz;

	@Override
	public String list(PageResult<T> page, Product product, User loginUser) {
		return productBiz.list(page,product,loginUser);
	}
	
	@Override
	public List<Product> list(Product product, User loginUser) {
		return productBiz.list(product,loginUser);
	}

	@Override
	public Product getById(Product product) {
		return productBiz.getById(product);
	}

	@Transactional
	@Override
	public JsonResult add(Product product, User loginUser) {
		if (productBiz.add(product, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(Product product, User loginUser) {
		if (productBiz.update(product, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(Product product, User loginUser) {
		if (productBiz.delete(product, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
